package cn.ehanghai.iot.common.security.constants;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by allenwc on 2017/2/15.
 */
public class Constants {

    public static final long EXPIRE_IN = 7200;

    public static final int ERROR_CODE_NONE = 0;
    public static final int ERROR_CODE_TOKEN_INVALID = 90;
    public static final int ERROR_CODE_MISSING_PARAM = 96;
    public static final int ERROR_CODE_SIGN_FAIL = 9;
    public static final int ERROR_CODE_BIZ_ERROR = 98;
    public static final int ERROR_CODE_SYSTEM_ERROR = 99;
    public static final int ERROR_CODE_TIMESTAMP_ERROR = 97;
    public static final int ERROR_CODE_MEMBER_ERROR = 80;
    public static final int ERROR_CODE_PASSWORD_ERROR=81;
    public static final int ERROR_CODE_MESSAGE_ISNULL=100;
    public static final int ERROR_CODE_MSGCODE_ERROR=101;
    public static final int ERROR_CODE_MSGCODE_NULL_OR_TIMEOUT=102;
    public static final int ERROR_CODE_SENDMESSAGE_ERROR=103;
    public static final int ERROR_CODE_IDCARD_ERROR=104;

    static Map<Integer, ReturnCode> codeMap = new HashMap<>();

    static {
        codeMap.put(ERROR_CODE_NONE,new ReturnCode(ERROR_CODE_NONE,"成功"));
        codeMap.put(ERROR_CODE_TOKEN_INVALID, new ReturnCode(ERROR_CODE_TOKEN_INVALID, "请求token无效"));
        codeMap.put(ERROR_CODE_MISSING_PARAM,new ReturnCode(ERROR_CODE_MISSING_PARAM,"请求参数缺失"));
        codeMap.put(ERROR_CODE_SIGN_FAIL,new ReturnCode(ERROR_CODE_SIGN_FAIL,"验签失败"));
        codeMap.put(ERROR_CODE_BIZ_ERROR,new ReturnCode(ERROR_CODE_BIZ_ERROR,"未知业务错误"));
        codeMap.put(ERROR_CODE_SYSTEM_ERROR,new ReturnCode(ERROR_CODE_SYSTEM_ERROR,"未知系统错误"));
        codeMap.put(ERROR_CODE_TIMESTAMP_ERROR,new ReturnCode(ERROR_CODE_TIMESTAMP_ERROR,"请求超时"));
        codeMap.put(ERROR_CODE_MEMBER_ERROR,new ReturnCode(ERROR_CODE_MEMBER_ERROR,"用戶不存在"));
        codeMap.put(ERROR_CODE_PASSWORD_ERROR,new ReturnCode(ERROR_CODE_PASSWORD_ERROR,"密码不对"));
        codeMap.put(ERROR_CODE_MESSAGE_ISNULL,new ReturnCode(ERROR_CODE_MESSAGE_ISNULL,"留言不存在"));
        codeMap.put(ERROR_CODE_MSGCODE_ERROR,new ReturnCode(ERROR_CODE_MSGCODE_ERROR,"验证码错误"));
        codeMap.put(ERROR_CODE_MSGCODE_NULL_OR_TIMEOUT,new ReturnCode(ERROR_CODE_MSGCODE_NULL_OR_TIMEOUT,"验证码不存在或者过期"));
        codeMap.put(ERROR_CODE_SENDMESSAGE_ERROR,new ReturnCode(ERROR_CODE_SENDMESSAGE_ERROR,"短信发送失败"));
        codeMap.put(ERROR_CODE_IDCARD_ERROR,new ReturnCode(ERROR_CODE_IDCARD_ERROR,"身份证号码不正确"));
    }

    public static ReturnCode getReturnCode(Integer code) {
        return codeMap.get(code);
    }


}
